var _n48;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$http_request = require("http_request");
var s = cc__importDefault($1$http_request);
var $1$userService = require("userService");
var c = cc__importDefault($1$userService);
var $1$zqcc_pageBase = require("zqcc_pageBase");
var l = cc__importDefault($1$zqcc_pageBase);
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Yinsi = function (t) {
  function _ctor() {
    const instance = (t !== null) ? t.apply(this, arguments) : this; // 调用t，或者使用当前上下文

    // 初始化属性
    instance.tishiLabel = null;
    instance.url = "https://changshazhise01-1254961065.cos.ap-guangzhou.myqcloud.com/zhise/oppo/test_email.json";

    return instance; // 返回对象
  }
  cc__extends(_ctor, t);
  _ctor.prototype.onLoad = function () {};
  _ctor.prototype.start = function () {
    s.default.getInstance().get(this.url, null, this.show.bind(this));
  };
  _ctor.prototype.show = function (t) {
    const instance = this; // 使用const定义实例
    const data = t; // 从参数 t 获取对象
    console.log(data); // 输出对象 data
    let resultString = ""; // 初始化字符串 resultString

    for (const key in data) { // 遍历对象 data
      if (Object.prototype.hasOwnProperty.call(data, key)) { // 确保是对象的自有属性
        const item = data[key]; // 获取属性值
        let formattedText = ""; // 初始化字符串 formattedText

        if (item.style?.bold) { // 使用可选链检查样式
          if (Array.isArray(item.test)) { // 检查 test 是否为数组
            formattedText = "<b>" + item.test.join('') + "</b>"; // 合并数组并包裹
          } else {
            formattedText = `<b>${item.text}</b>`; // 如果不是数组，直接使用 text
          }
        } else if (Array.isArray(item.test)) {
          formattedText = item.test.join(''); // 合并数组元素
        } else {
          formattedText = item.text; // 处理一般文本
        }
        resultString += formattedText; // 加入到最终字符串 resultString
      }
    }

    // 替换 company 和 email
    resultString = resultString
      .replace(/company/gi, c.default.vivoSDKdata.zs_company)
      .replace(/email/gi, "email:" + c.default.vivoSDKdata.zs_postbox);

    // 设置 tishiLabel 的字符串
    instance.tishiLabel.string = resultString;

    // 定时调整父节点高度
    instance.scheduleOnce(() => {
      instance.tishiLabel.node.parent.height = instance.tishiLabel.node.height;
    });

  };
  cc__decorate([ccp_property(cc.RichText)], _ctor.prototype, "tishiLabel", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(l.default);
exports.default = def_Yinsi;